Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uses pthreads over spinlocks and also little revise of structures used in the code #638

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kqiq
Copy link

@kqiq kqiq commented Jan 9, 2023

little overview of what i changed and explanation of used structured within the code :

  • uses pthreads mutexes instead of spinlocks to synchronize access to the buffer cache and individual buffers. also removes the sleeplock functionality and replaces it with simple mutexes for simplicity. bget function returns NULL if no buffer is available rather than panicking. bread function returns NULL if the read from the disk fails or if no buffer is available. bwrite function returns a boolean indicating whether the write to the disk was successful. brelse function no longer takes a spinlock on the buffer cache before releasing the buffer lock.

  • buf structure gonna represents a buffer in the buffer cache. It stores the device and block number of the block that the buffer holds, a flag indicating whether the buffer's data is valid anda reference count indicating how many users have a reference to the buffer

  • buf_cache structure represents the buffer cache stores an array of buf structures act as a linked list of buffers sorted by how recently they were used.

  • buf_cache_init function initializes the buffer cache by initializing the mutex and creating the linked list of buffers.

hope to help ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant